package com.molin.networkTest.socketTest.demo2;

import java.io.IOException;
import java.net.*;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //1.找码头
        DatagramSocket datagramSocket=new DatagramSocket();
        //2.打包礼物
        String s="送给老丈人的礼物";
        byte[] bytes = s.getBytes();
        DatagramPacket dp=new DatagramPacket(bytes,bytes.length, InetAddress.getByName("127.0.0.1"),8888);

        //3.由码头发送包裹
        datagramSocket.send(dp);
        //4.付钱走人
        datagramSocket.close();
    }
}
